// 1. 创建一个接口。
interface Shape {
    draw(): void;
}

// 2. 创建实现接口的实体类。
class Circle implements Shape {
    draw() {
        console.log('Circle::draw()');
    }
}

class Rectangle implements Shape {
    draw() {
        console.log('Rectangle::draw()');
    }
}

class Square implements Shape {
    draw() {
        console.log('Square::draw()');
    }
}

// 3. 创建一个外观类。
class ShapeMaker {
    private circle: Shape;
    private rectangle: Shape;
    private square: Shape;

    constructor() {
        this.circle = new Circle();
        this.rectangle = new Rectangle();
        this.square = new Square();
    }

    drawCircle() {
        this.circle.draw();
    }

    drawRectangle() {
        this.rectangle.draw();
    }

    drawSquare() {
        this.square.draw();
    }
}

// 4. 使用该外观类画出各种类型的形状。
const shapeMaker = new ShapeMaker();

shapeMaker.drawCircle();
shapeMaker.drawRectangle();
shapeMaker.drawSquare();

